<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>积分兑换设置管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$('#validDays').val('${scoreExchange.validDays}');
			$('#cycleType').val('${scoreExchange.cycleType}');
			
			var autoClear  = '${scoreExchange.autoClear}';
			autoClear = (signSwitch!="1") ? "0" :"1";
			$("input[type='radio'][name='autoClear'][value='"+autoClear+"']").attr("checked", "checked");
			
			
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/score/scoreExchange/">积分对换设置列表</a></li>
		<li class="active"><a href="${ctx}/score/scoreExchange/form?id=${scoreExchange.id}">积分对换设置<shiro:hasPermission name="score:scoreExchange:edit">${not empty scoreExchange.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="score:scoreExchange:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="scoreExchange" action="${ctx}/score/scoreExchange/save" method="post" class="form-horizontal" enctype="multipart/form-data">
		<form:hidden path="id"/>
		<form:hidden path="user.id"/>
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">名称:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="50" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">对应优惠券:</label>
			<div class="controls">
				 <form:select path="couponId">
				 	<c:forEach items="${couponList}" var="coupon">
	                    <form:option value="${coupon.id}">${coupon.name}</form:option>
					</c:forEach>
         		</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">积分值:</label>
			<div class="controls">
				<form:input path="score" htmlEscape="false" maxlength="11" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">微信关键字:</label>
			<div class="controls">
				<form:input path="message" htmlEscape="false" maxlength="100" class="required"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">是否自动核销:</label>
			<div class="controls">
				<input type="radio" name="autoClear"  value="1"/>是 &nbsp;<input type="radio" name="autoClear" checked="checked" value="0"/>否
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">积分类型:</label>
			<div class="controls">
				<label> <form:radiobutton path="payType"  value="0"  />积分 </label>
				<label> <form:radiobutton path="payType"  value="1"  />活动币</label>    
				<label> <form:radiobutton path="payType"  value="2"  />三级推广活动币</label>    
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">类型:</label>
			<div class="controls">
				<label> <form:radiobutton path="type"  value="2"  checked="checked "/>兑换储值</label>&nbsp;&nbsp;&nbsp;<%-- <label> <form:radiobutton path="type"  value="3"  />兑换现金红包 </label>  --%>  
				<span class="alert">注：需要是积分才能进行兑换</span>   
			</div>
		</div>
		
		 
		<div class="control-group">
			<label class="control-label">金额:</label>
			<div class="controls">
				<form:input path="money" htmlEscape="false" maxlength="11" class="required"/><span class="alert">注：兑换金额，以‘分’为单位</span>   
			</div>
		</div>
		
		
		
		
		
		<div class="control-group">
			<label class="control-label">兑换数量:</label>
			<div class="controls">
				<form:input path="number" htmlEscape="false" maxlength="100" class="required"/>
				<span class="alert">0为不能兑换</span>  
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">剩余数量:</label>
			<div class="controls">
				<form:input path="exchangeNumber" htmlEscape="false" maxlength="100" />
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">兑换次数:</label>
			<div class="controls">
				<form:input path="count" htmlEscape="false" maxlength="100" class="required" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
				<span class="alert">0为不限次数</span>  
			</div>
		</div>
		
		
		
		<div class="control-group">
			<label class="control-label">限制周期:</label>
				<div class="controls">
				<select name="cycleType" id="cycleType">
					<option value="0" >不限</option>
					<option value="2" >按月限制</option>
				</select>
			</div>
		</div>
		
		
		
		<div class="control-group">
			<label class="control-label">有效天数:</label>
				<div class="controls">
				<select name="validDays" id="validDays">
					<% for(int i=1;i<31;i++) {%>
					<option value="<%=i%>" ><%=i %>天</option>
					<%} %>
				</select>
			</div>
		</div>
		
		<!-- 
			<div class="control-group">
				<label class="control-label">有效果时间:</label>
				<div class="controls">
						<script src="${ctxStatic}/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
						<input id="startTime" name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
							value="<fmt:formatDate value="${scoreExchange.startTime}" pattern="yyyy-MM-dd"/>"
							onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>  至
						<input id="endTime" name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
							value="<fmt:formatDate value="${scoreExchange.endTime}" pattern="yyyy-MM-dd"/>"
							onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
				</div>
			</div>
		 -->
		
		<div class="control-group">
			<label class="control-label">商品展示图片:</label>
			<div class="controls">
				<c:if test="${scoreExchange.showPic ne '' }">
					<div class="control"><img src="${ctxUser }/score/${scoreExchange.showPic }" style="width:300px;height:100px"/></div>
				</c:if>
				<div class="control">
					<input type="file" name="ShowPicfile" htmlEscape="false"   />    <span class="alert">建议尺寸：128像素 * 128像素 </span>      
				</div>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">备注:</label>
			<div class="controls">
				<form:input path="remarks" htmlEscape="false" maxlength="50" />
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">详细:</label>
			<div class="controls">
				<form:textarea id="xqing" htmlEscape="true"  path="xqing" rows="4" maxlength="200" class="input-xxlarge required"/>
				<tags:ckeditor replace="xqing" uploadPath="/cms/article" />
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">是否为口罩:</label>
			<div class="controls">
				<label> <form:radiobutton path="iskou"  value="0"  />不是</label>
				<label> <form:radiobutton path="iskou"  value="1"  />是</label>    
			</div>
		</div>
		
		<div class="form-actions">
			<shiro:hasPermission name="score:scoreExchange:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
